import 'package:trollee/app/components/custom_app_bar.dart';
import 'package:trollee/app/components/custom_button.dart';
import 'package:trollee/app/components/dialog/app_alert_dialog.dart';
import 'package:trollee/app/components/dialog/app_bottom_dialog.dart';
import 'package:trollee/app/components/toast_widget.dart';
import 'package:trollee/app/core/core.dart';
import 'package:trollee/app/modules/profile/profile/controller.dart';

class ProfilePage extends StatelessWidget {
  ProfilePage({Key? key}) : super(key: key);

  final controller = Get.put(ProfileController());
  final states = Get.find<ProfileController>().states;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CustomAppBar(titleText: '个人中心'),
      body: SingleChildScrollView(
        padding: EdgeInsets.symmetric(horizontal: AppDimens.dp16),
        child: Column(
          children: [
            AppGaps.vGap16,
            CustomButton(
                text: '点击修改用户信息',
                onPressed: () {
                  final userInfo = UserManager.getUser();
                  if (userInfo != null) {
                    UserManager.saveUser(userInfo..username = '修改后昵称');
                    AppToast.showSuccess('修改成功,首页发生变化');
                  }
                }),
            Text('测试图标显示', style: AppTextStyles.body2_12_Regular_primary),
            AppGaps.vGap8,
            Row(
              children: [
                Icon(
                  AppIcons.general_ic_add,
                  size: AppDimens.dp24,
                ),
                AppGaps.hGap4,
                Icon(
                  AppIcons.general_ic_info,
                  size: AppDimens.dp24,
                ),
                AppGaps.hGap4,
                Icon(
                  AppIcons.ic_route,
                  size: AppDimens.dp24,
                  color: AppColors.primary_color,
                ),
                AppGaps.hGap4,
                Icon(AppIcons.ic_down, size: AppDimens.dp24, color: AppColors.meaning_color_danger),
              ],
            ),
            AppGaps.vGap8,
            CustomButton(
              text: '显示弹框',
              onPressed: () {
                AppAlertDialog.showText(text: '弹框内容弹框内容弹框内容弹框内容');
              },
            ),
            AppGaps.vGap8,
            CustomButton(
              text: '显示底部弹框',
              onPressed: () {
                AppBottomDialog.showText(text: '弹框内容弹框内容弹框内容弹框内容');
              },
            ),
            AppGaps.vGap8,
            CustomButton(
              text: '显示Toast',
              onPressed: () {
                AppToast.show('text');
              },
            ),
            AppGaps.vGap8,
            Text('国际化测试', style: AppTextStyles.body2_12_Regular_primary),
            AppGaps.vGap8,
            Text('当前语言环境: ${AppLocaleUtil.currentLocale}', style: AppTextStyles.body1_14_Regular_primary),
            Text('key1'.tr, style: AppTextStyles.body1_14_Regular_primary),
            Text(
              'key2'.trParams({'name': 'Flutter'}),
              style: AppTextStyles.body1_14_Regular_primary,
            ),
            AppGaps.vGap8,
            CustomButton(
              text: '修改语言',
              onPressed: () {
                AppLocaleUtil.updateLang(AppLocaleUtil.isChinese() ? AppLocaleUtil.EN_US : AppLocaleUtil.ZH_CN);
              },
            ),
          ],
        ),
      ),
    );
  }
}
